<?

$id = $_SESSION['userid'];
echo "id: " . $id;

try {
    $user = $qm->getUserById($id);
    $characters = $user->getCharacters();

echo "<p>Your Characters:</p>";
echo "<div id=\"character_menu\">";

foreach($user->getCharacters() as $character) {
    echo"<a href=\"#\" class=\"character\">";
        echo"<div class=\"left\">";
            echo"<img src=\"img/character_menu_name.png\" />";
            echo $character->getName();
            echo "<br />";
            echo"<img src=\"img/character_menu_place.png\" />Doreiken Vallei";
        echo"</div>";
        echo"<div class=\"right\">";
            echo"<span class=\"activity\">walking: 54%</span>";
        echo"</div>";
    echo"</a>";
}
    

/*

    if(isset($_GET['edit']) && is_numeric($_GET['edit'])) {
        $editChar = $qm->getCharacterFromIdWithName($_GET['edit'], $character);
        if(isset($_POST['submit'])) {
            $editChar->setName($_POST['name']);
            $qm->setCharacterFromIdWithName($editChar, $character);
        }

        try {

?>
<form method="post" action="">
    Name: <input type="input" name="name" value="<?php echo $editChar->getName(); ?>" />
    <input type="submit" name="submit" value="Save" />
</form>

<?php
        } catch(QueryException $e) {
            print_r($e->getMessage());
        }
    } else {



        echo "<p>Users on the location of " . $character->getName() . ":</p>";
        echo "<ul>";
        foreach($character->getLocation()->getCharacters($character) as $char) {
            echo "<li><a href=\"?edit=".$char->getId()."\">".$char->getName()."</a></li>";
        }
        echo "</ul>";

    }
 */
} catch(QueryException $e) {
    print_r($e->getMessage());
}

?>


    <a href="#" class="character">
        <div class="left">
            <img src="img/character_menu_name.png" />Doekoe Dijkstra<br />
            <img src="img/character_menu_place.png" />Erbuzalem
        </div>
        <div class="right">
            <span class="activity">baking: 78%</span>
        </div>
    </a>

    <a href="#" class="character">
        <div class="left">
            <img src="img/character_menu_name.png" />Ernst-Jan<br />
            <img src="img/character_menu_place.png" />Gop Beach
        </div>
        <div class="right">
            <span class="activity">surfing: 23%</span>
        </div>
    </a>
        <a href="#" id="plus">add new</a>
</div>